const http = require('../utils/http.js');
const { data } = require('../utils/res.js');

// 新增订单
const newOrder = (data) => {
    return http.request('POST', `/Order`, data)
}

// 获取订单列表
const orderList = (data) => {
    return http.request('POST', `/Order/page`, data)
}

// 获取订单详情
const orderDetail = (id) => {
    return http.request('GET', `/Order/${id}`)
}

// 取消订单
const cancelOrder = (orderId) => {
    return http.request('GET', `/Order/cancelOrder/${orderId}`)
}

// 删除订单
const deleteOrder = (orderId) => {
    return http.request('GET', `/Order/deleteOrder/${orderId}`)
}

// 完成订单（确认收货）
const completeOrder = (orderId) => {
    return http.request('GET', `/Order/completeOrder/${orderId}`)
}

// 秒杀提交订单
const newSeckillOrder = (data) => {
    return http.request('POST', '/Order/seckill', data)
}

// 拼团订单下单
const newGroupOrder = (data) => {
    return http.request('POST', '/Order/spell', data)
}

// 补货下单
const replenishment = (data) => {
    return http.request('POST', '/Order/replenishment', data)
}

// 自提下单
const selfOrder = (data) => {
    return http.request('POST', '/Order/abholung', data)
}

// 获取折扣信息
const getDiscount = ()=>{
    return http.request('GET','/Common/memberGrades')
}

module.exports = {
    newOrder,
    orderList,
    orderDetail,
    cancelOrder,
    deleteOrder,
    completeOrder,
    newSeckillOrder,
    newGroupOrder,
    replenishment,
    selfOrder,
    getDiscount
}